package net.cloudbusniness.cloudbusinessclient.base;

import android.content.Context;


/**
 * Created by hulei on 2017/2/17
 */
public abstract class BasePresenterImp<MImp extends BaseModelImp> implements BasePresenter {

    protected Context mContext;
    protected BaseView mBaseView;
    protected MImp mModelImp;

    public void setPresenterImp(Context context, BaseView baseView) {
        this.mContext = context;
        this.mBaseView = baseView;
        try {
            this.mModelImp = onSetModelImp().newInstance();
            this.mModelImp.setModelImp(mContext, this);
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (NullPointerException e){
            e.printStackTrace();
        }
    }

    @Override
    public void dataCallBack(CallBackType Type, int requestId, Object object){
        this.mBaseView.dataCallBack(Type, requestId, object);
    }

    protected abstract Class<MImp> onSetModelImp();
}
